package scau.edu.cn.repository;

import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.query.Param;
import scau.edu.cn.entity.QueryEntity;

import javax.transaction.Transactional;

/**
 * @description:问卷实体DAO
 * @author: yuxiang
 * @create: 2020-08-15 14:31
 **/
public interface QueryRepository  extends JpaRepository<QueryEntity,String>, JpaSpecificationExecutor<QueryEntity> {

    /**
     * 根据Id查问卷实体
     * @param id
     * @return
     */
    QueryEntity findQueryEntityById(String id);

    /**
     * 更改问卷状态为1
     * @param i
     * @return
     */
    @Modifying
    @Transactional
    @Query("update QueryEntity qt set qt.flag =:flag where qt.id =:id")
    int updateFlagById(@Param("id") String id,@Param("flag") int i);
}